﻿using System;
using System.Diagnostics;
using Newtonsoft.Json;

namespace WinLiveHelper.Wp7
{
	[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
	public class Calendar : Bindable
	{
		private string _id;
		[JsonProperty(PropertyName="id")]
		public string Id
		{
			[DebuggerStepThrough]
			get { return _id; }
			set
			{
				if (value != _id)
				{
					_id = value;
					OnPropertyChanged("Id");
				}
			}
		}

		private string _name;
		[JsonProperty(PropertyName="name")]
		public string Name
		{
			[DebuggerStepThrough]
			get { return _name; }
			set
			{
				if (value != _name)
				{
					_name = value;
					OnPropertyChanged("Name");
				}
			}
		}

		private string _description;
		[JsonProperty(PropertyName = "description")]
		public string Description
		{
			[DebuggerStepThrough]
			get { return _description; }
			set
			{
				if (value != _description)
				{
					_description = value;
					OnPropertyChanged("Description");
				}
			}
		}

		private DateTime _createdTime;
		[JsonProperty(PropertyName="created_time")]
		[JsonConverter(typeof(IsoDateTimeToUtcConverter))]
		public DateTime CreatedTime
		{
			[DebuggerStepThrough]
			get { return _createdTime; }
			set
			{
				if (value != _createdTime)
				{
					_createdTime = value;
					OnPropertyChanged("CreatedTime");
				}
			}
		}

		private DateTime _updatedTime;
		[JsonProperty(PropertyName = "updated_time")]
		[JsonConverter(typeof(IsoDateTimeToUtcConverter))]
		public DateTime UpdatedTime
		{
			[DebuggerStepThrough]
			get { return _updatedTime; }
			set
			{
				if (value != _updatedTime)
				{
					_updatedTime = value;
					OnPropertyChanged("UpdatedTime");
				}
			}
		}

		private From _from;
		[JsonProperty(PropertyName = "from")]
		public From From
		{
			[DebuggerStepThrough]
			get { return _from; }
			set
			{
				if (value != _from)
				{
					_from = value;
					OnPropertyChanged("From");
				}
			}
		}

		private bool _isDefault;
		[JsonProperty(PropertyName = "is_default")]
		public bool IsDefault
		{
			[DebuggerStepThrough]
			get { return _isDefault; }
			set
			{
				if (value != _isDefault)
				{
					_isDefault = value;
					OnPropertyChanged("IsDefault");
				}
			}
		}

		private string _subscriptionLocation;
		/// <summary>
		/// NOTE: Do not include when creating a new calendar on the server.
		/// </summary>
		[JsonProperty(PropertyName = "subscription_location")]
		public string SubscriptionLocation
		{
			[DebuggerStepThrough]
			get { return _subscriptionLocation; }
			set
			{
				if (value != _subscriptionLocation)
				{
					_subscriptionLocation = value;
					OnPropertyChanged("SubscriptionLocation");
				}
			}
		}

		private string _permissions;
		[JsonProperty(PropertyName = "permissions")]
		public string Permissions
		{
			[DebuggerStepThrough]
			get { return _permissions; }
			set
			{
				if (value != _permissions)
				{
					_permissions = value;
					OnPropertyChanged("Permissions");
				}
			}
		}
	}
}